﻿using System;
using System.Collections.Generic;
using System.Linq;
using Complaint.Models.Dtos;
using Complaint.Repositories;

namespace Complaint.Models
{
    public class SettlementTypeModel : BaseModel<SettlementTypeRepository>,
        IModel<SettlementType>
    {
        #region Implementation of IModel<SettlementType>

        /// <summary>
        /// Retrieves all instances of the type T.
        /// </summary>
        /// <returns>The requested instances.</returns>
        public IList<SettlementType> Retrieve()
        {
            return Repository.FindAll().ToList();
        }

        /// <summary>
        /// Creates the passed dto in the data store.
        /// </summary>
        /// <param name="dto">The data transfer object containing the new values.</param>
        public void Create(SettlementType dto)
        {
            if (dto != null) Repository.Create(dto);
        }

        /// <summary>
        /// Updates the passed dto in the data store.
        /// </summary>
        /// <param name="dto">The data transfer object containing the new values.</param>
        public void Update(SettlementType dto)
        {
            if (dto != null) Repository.Update(dto);
        }

        /// <summary>
        /// Deletes the passed dto from the data store.
        /// </summary>
        /// <param name="dto">The data transfer object to delete.></param>
        public void Delete(SettlementType dto)
        {
            if (dto != null) Repository.Delete(dto);
        }

        /// <summary>
        /// Retrieves all instances of the type T with the matching name.
        /// </summary>
        /// <param name="name">The name of the instances to retrieve.</param>
        /// <returns>The requested instances.</returns>
        public IList<SettlementType> FindByName(string name)
        {
            return Repository.FindByName(name).ToList();
        }

        /// <summary>
        /// Retrieves an instances of the type T with the matching id.
        /// </summary>
        /// <param name="id">The Id of the instance to retrieve.</param>
        /// <returns>The requested instances.</returns>
        public SettlementType FindById(int id)
        {
            return Repository.FindById(id);
        }

        #endregion
    }
}
